package trocabi.Renderer;

import java.awt.Color;
import java.awt.Component;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

public class ColorCellRenderer extends DefaultTableCellRenderer {

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

        String color = (String) value;

        setText("");
        switch (color) {
            case "Bleu":
                setBackground(Color.BLUE);
                break;
            case "Rouge":
                setBackground(Color.RED);
                break;
            case "Jaune":
                setBackground(Color.YELLOW);
                break;
            case "Vert":
                setBackground(Color.GREEN);
                break;
            case "Blanc / Beige":
                setBackground(Color.WHITE);
                break;
            case "Noir":
                setBackground(Color.BLACK);
                break;
            case "Rose":
                setBackground(Color.PINK);
                break;
            case "Violet":
                setBackground(Color.MAGENTA);
                break;
        }

        return this;
    }
}
